package com.showgood.beans.handler.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.showgood.beans.handler.SingleVoArrayReplyHandler;
import com.showgood.beans.proxy.GameUtil;
import com.showgood.beans.service.impl.CityService;
import com.showgood.meta.City;
import com.showgood.socket.Session;
import com.showgood.util.math.Rect;
import com.showgood.vo.CityVO;
import com.showgood.vo.RectVO;
import com.showgood.vo.RemoteMessage;

@Component
public class QueryCityHandler extends SingleVoArrayReplyHandler<RectVO, CityVO> {
	@Autowired
	private CityService cityService;
	@Override
	public int[] handleMessage() {
		return new int[]{RemoteMessage.REMOTE_QUERY_CITY_ON_MAP};
	}
	@Override
	protected List<CityVO> handle(Session userSession, RectVO vo) {
		// logger.info(gameUtil.toJSON(vo));
		List<City> cityList = cityService.findInRect(GameUtil.copyTo(vo, new Rect()));
		return GameUtil.conv(cityList, CityVO.class);
	}
}

